#include "stack.h"

void Stack::Init()
{
	int* tmp = (int*)malloc(sizeof(int) * 4);
	if (tmp == nullptr)
	{
		perror("malloc fail");
		exit(-1);
	}
	_nums = tmp;
	_top = 0;
	_capacity = 4;
}

void Stack::Destroy()
{
	if (_nums)
	{
		free(_nums);
		_nums = nullptr;
		_top = _capacity = 0;
	}
}